From: Robert Lipe Date: Fri, 30 Dec 2016 00:27:24 +0000 (-0600) Subject: Add the minimum_points option to trackfilter for OSM users. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~9^2~8 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9cdbfc777ed22abfc95dda49209591f95a42be85;p=gpsbabel.git Add the minimum_points option to trackfilter for OSM users. --- diff --git a/trackfilter.cc b/trackfilter.cc index aff04c14d..9005f8903 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -52,6 +52,7 @@ #define TRACKFILTER_SEGMENT_OPTION "segment" #define TRACKFILTER_FAKETIME_OPTION "faketime" #define TRACKFILTER_DISCARD_OPTION "discard" +#define TRACKFILTER_MINPOINTS_OPTION "minimum_points" #undef TRACKF_DBG @@ -72,6 +73,7 @@ static char* opt_trk2seg = NULL; static char* opt_segment = NULL; static char* opt_faketime = NULL; static char* opt_discard = NULL; +static char* opt_minpoints = NULL; static arglist_t trackfilter_args[] = { @@ -156,6 +158,11 @@ arglist_t trackfilter_args[] = { "Discard track points without timestamps during merge", NULL, ARGTYPE_BOOL, ARG_NOMINMAX }, + { + TRACKFILTER_MINPOINTS_OPTION, &opt_minpoints, + "Discard tracks with fewer than these points", + NULL, ARGTYPE_INT, "0" + }, ARG_TERMINATOR }; @@ -311,7 +318,7 @@ trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_d Waypoint* wpt, *prev; queue* elem, *tmp; - if (track->rte_waypt_ct == 0) { + if (track->rte_waypt_ct == 0 ) { track_del_head((route_head*)track); return; } @@ -364,6 +371,16 @@ trackfilter_fill_track_list_cb(const route_head* track) /* callback for track_d track_ct++; } +static void +trackfilter_minpoint_list_cb(const route_head* track) +{ + int minimum_points = atoi(opt_minpoints); + if (track->rte_waypt_ct < minimum_points ) { + track_del_head((route_head*)track); + return; + } +} + /******************************************************************************* * track title producers *******************************************************************************/ @@ -458,7 +475,7 @@ trackfilter_pack(void) prev = track_list[j]; if (prev.last_time >= track_list[i].first_time) { fatal(MYNAME "-pack: Tracks overlap in time! %s >= %s at %d\n", - qPrintable(prev.last_time.toString()), + qPrintable(prev.last_time.toString()), qPrintable(track_list[i].first_time.toString()), i); } } @@ -1375,6 +1392,11 @@ trackfilter_process(void) trackfilter_split(); } + + // Performed last as previous options may have created "small" tracks. + if ((opt_minpoints != NULL) && atoi(opt_minpoints) > 0) { + track_disp_all(trackfilter_minpoint_list_cb, NULL, NULL); + } } /******************************************************************************************/ diff --git a/xmldoc/filters/options/track-minimum_points.xml b/xmldoc/filters/options/track-minimum_points.xml new file mode 100644 index 000000000..31b79a929 --- /dev/null +++ b/xmldoc/filters/options/track-minimum_points.xml @@ -0,0 +1,8 @@ + +Eliminates any remaining tracks with fewer than this number of trackpoints. + + +This step is performed last by this filter and is used to clean up earlier +simplifications that may have left tracks with so few points as to be +useless, such as a track taken while stationary but with GPS wander. +